package cn.kgc.springmvc.controller;

import cn.kgc.springmvc.entity.User;
import cn.kgc.springmvc.util.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author: mosin
 * @version: v1.0  2022/5/4
 */
@Controller
@RequestMapping("/json")
public class JSONController {
    @RequestMapping("/js1")
    //@ResponseBody // 返回的结果以json格式进行返回
    public Object test01(){
        User user = new User();
        user.setName("tom");
        user.setPassword("123456");
        Result<User> result = new Result<>();
        result.setCode(200);
        result.setCount(10);
        result.setMsg("ok");
        result.setData(user);
        return  result;
    }

    @RequestMapping("/js2")
    public String test02(){
        return "index";
    }

}
